var vm = new Vue({
    el:"#app",
    data(){
        return {
            //初始化
            InitForm:{
                nowdate:'',
                Store:'',
                UserNo:'',
                UserName:''
            },
            CaculateForm:{
                CylServiceTotal:'',
                CylTotal:'',
                CylRate:''
            },

            //搜索条件
            Theme:'',
            Store:'',
            CyStartDate:'',
            CyEndDate:'',
            ThemeList:[],
            formItem: {
                DealerNo: '',
                Name:'',
                Remark:''
            },
            EditFormItem:{
                DealerNo: '',
                Name:'',
                Remark:''
            },
            modal1:false, //添加经销商弹框
            modal2:false, //编辑经销商弹框
            //搜索结果
            columns1: [
                {
                    type: 'index',
                    title: '序号',
                    width:46,
                    align: 'center',
                },
                {
                    title: '店面',
                    key: 'Store',
                    align: 'center',
                },
                {
                    title: '主题',
                    key: 'Theme',
                    align: 'center',
                },
                {
                    title: '项目名称',
                    key: 'PName',
                    align: 'center',
                },
                {
                    title: '参与数量',
                    key: 'CyNum',
                    align: 'center',
                    width:300
                },
                {
                    title: '日期',
                    key: 'EditDate',
                    align: 'center',
                },
                {
                    title: '录入人',
                    key: 'InputManName',
                    align: 'center',
                },
             /*   {   title: '操作',
                    key: 'action',
                    align: 'center',
                    width:150,
                    render: (h, params) => {
                        return h('div', [
                            h('a', {
                                style: {
                                    marginRight: '5px',
                                    border : '0',
                                    fontSize: '14px',
                                },
                                on: {
                                    click: () => {
                                        this.EditFormItem.DealerNo = params.row.DealerNo;
                                        this.EditFormItem.Name = params.row.Name;
                                        this.EditFormItem.Remark = params.row.Remark;
                                        this.modal2=true;
                                    }
                                }
                            },'编辑'),
                            h('span', {
                            },'|'),
                            h('a', {
                                style: {
                                    marginLeft: '5px',
                                    border : '0',
                                    fontSize: '14px',
                                },
                                on: {
                                    click: () => {
                                        var DealerNo = params.row.DealerNo;
                                        this.confirm(DealerNo);
                                    }
                                }
                            },'删除')
                        ])
                    }
                }*/
            ],
            data1: [],

        }
    },
    created(){
        this.initThisPage();
        this.queryTheme();
    },
    methods:{
        ok () {
        },
        cancel () {
        },
        confirm (DealerNo) {
            var self = this;
            this.$Modal.confirm({
                title: '提示',
                content: '<p>是否删除</p>',
                onOk: () => {
                    self.delDealer(DealerNo);
                },
                onCancel: () => {
                    toastr.info("取消删除");
                }
            });
        },
        querytable(){
            var self = this;
            var info ;
            var Store = self.Store;
            var CyStartDate = self.CyStartDate;
            var CyEndDate = self.CyEndDate;
            var Theme = self.Theme;
            var jsondata={"Store":Store,"CyStartDate":CyStartDate,"CyEndDate":CyEndDate,"Theme":Theme};
            var data_json = JSON.stringify(jsondata);
            $.ajax({
                url: "./goCyl/queryCylCaculate", //请求的url地址
                dataType: "json", //返回格式为json
                data: data_json, //参数值
                async:false,
                type: "POST", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                success: function(data) {
                    info = eval(data.ServiceResultList);
                    self.CaculateForm.CylServiceTotal = data.CylServiceTotal;
                    self.CaculateForm.CylTotal = data.CylTotal;
                    self.CaculateForm.CylRate = data.CylRate;
                },
                error: function() {},
            });
            if(info){
                self.data1 = info;
            }
        },
        initThisPage(){
            var self = this;
            $.ajax({
                url: "./goLogin/initIndexPage", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                async:false,
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                processData: false, //对表单data数据是否进行序列化
                contentType: false, //dataType设置你收到服务器数据的格式
                headers: {
                    'Content-Type': 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    if(data.Status==0){
                        // top.location.href = "../../login.html";
                        window.location.href="../../login.html";
                    }else if(data.Status=1){
                        if(data.Store=='运营管理中心'){
                            self.InitForm.nowdate = data.nowdate;
                            self.InitForm.Store = data.Store;
                            self.InitForm.UserNo = data.UserNo;
                            self.InitForm.UserName = data.UserName;
                        }else{
                            $("#StoreLim").attr("disabled", true);
                            self.Store = data.Store;
                            self.InitForm.nowdate = data.nowdate;
                            self.InitForm.Store = data.Store;
                            self.InitForm.UserNo = data.UserNo;
                            self.InitForm.UserName = data.UserName;
                        }
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function() {}
            });
        },
        queryTheme(){
            var self = this;
            $.ajax({
                url: "./goProject/queryTheme", //请求的url地址
                xhrFields: {
                    withCredentials: true
                },
                dataType: "json", //返回格式为json
                type: "GET", //请求方式
                headers : {
                    'Content-Type' : 'application/json'
                },
                beforeSend: function() {
                    //请求前的处理
                },
                success: function(data) {
                    var ThemeList = data.ThemeList;
                    for(var i=0;i<ThemeList.length;i++){
                        var temp = {
                            value: ThemeList[i].ThemeName,
                            label: ThemeList[i].ThemeName
                        };
                        self.ThemeList.push(temp)
                    }
                },
                complete: function() {
                    //请求完成的处理
                },
                error: function(data) {

                }
            });
        },
        //手机号验证
        isPoneAvailable(str) {
            var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
            if (!myreg.test(str)) {
                return false;
            } else {
                return true;
            }
        },
        //uuid
        uuid(len, radix) {
            var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
            var uuid = [], i;
            radix = radix || chars.length;

            if (len) {
                // Compact form
                for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
            } else {
                // rfc4122, version 4 form
                var r;

                // rfc4122 requires these characters
                uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
                uuid[14] = '4';

                // Fill in random data. At i==19 set the high bits of clock sequence as
                // per rfc4122, sec. 4.1.5
                for (i = 0; i < 36; i++) {
                    if (!uuid[i]) {
                        r = 0 | Math.random()*16;
                        uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
                    }
                }
            }

            return uuid.join('');
        }
    }
})